#pragma once

#include <windows.h>
#include <max.h>
#include <impexp.h>
#include <igame.h>
#include <iconversionmanager.h>
#include <vector>

#include "..\..\CommonIncludes\IProgressSubject.h"
#include "..\..\CommonIncludes\IProgressObserver.h"
#include "..\..\CommonIncludes\IExportInterface.h"

#include "scene3d/SGMDataCollector.h"

class SGMExporter : public IExportInterface
{
private:
	std::vector<IProgressObserver*> observers;
	char *file_name;

	void ExportScene(SGMDataCollector *sgm_data);

	void ExportObjects(IGameScene *igame_scene, SGMDataCollector *sgm_data);
	void ExportNode(IGameScene *igame_scene, IGameNode *igame_node, SGMDataCollector *sgm_data);

	void CollectMesh(IGameScene *igame_scene, IGameNode *igame_node, IGameMesh *igame_mesh, SGMDataCollector *sgm_data);
	void CollectFaces(IGameMesh *igame_mesh, Scene3DMesh *mesh, SGMDataCollector *sgm_data);
	void CollectVerts(IGameMesh *igame_mesh, Scene3DMesh *mesh, SGMDataCollector *sgm_data);
	void CollectNormals(IGameMesh *igame_mesh, Scene3DMesh *mesh, SGMDataCollector *sgm_data);
	void CollectCoords(IGameMesh *igame_mesh, Scene3DMesh *mesh, SGMDataCollector *sgm_data);

	void SetProgressSteps(int progressSteps);
	void StepProgress();

public:
	bool DoExport(const TCHAR *name, ExpInterface *ei, Interface *i); 
	const char *GetResultMessage();

	void RegisterObserver(IProgressObserver *observer);
	void UnregisterObserver(IProgressObserver *observer);
};
